import 'package:tender_flutter/page/supplier/model/supplier_entity.dart';

supplierEntityFromJson(SupplierEntity data, Map<String, dynamic> json) {
	if (json['pageNum'] != null) {
		data.pageNum = json['pageNum'] is String
				? int.tryParse(json['pageNum'])
				: json['pageNum'].toInt();
	}
	if (json['pageSize'] != null) {
		data.pageSize = json['pageSize'] is String
				? int.tryParse(json['pageSize'])
				: json['pageSize'].toInt();
	}
	if (json['total'] != null) {
		data.total = json['total'] is String
				? int.tryParse(json['total'])
				: json['total'].toInt();
	}
	if (json['pages'] != null) {
		data.pages = json['pages'] is String
				? int.tryParse(json['pages'])
				: json['pages'].toInt();
	}
	if (json['list'] != null) {
		data.xList = new List<SupplierList>();
		(json['list'] as List).forEach((v) {
			data.xList.add(new SupplierList().fromJson(v));
		});
	}
	if (json['isFirstPage'] != null) {
		data.isFirstPage = json['isFirstPage'];
	}
	if (json['isLastPage'] != null) {
		data.isLastPage = json['isLastPage'];
	}
	return data;
}

Map<String, dynamic> supplierEntityToJson(SupplierEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['pageNum'] = entity.pageNum;
	data['pageSize'] = entity.pageSize;
	data['total'] = entity.total;
	data['pages'] = entity.pages;
	if (entity.xList != null) {
		data['list'] =  entity.xList.map((v) => v.toJson()).toList();
	}
	data['isFirstPage'] = entity.isFirstPage;
	data['isLastPage'] = entity.isLastPage;
	return data;
}

supplierListFromJson(SupplierList data, Map<String, dynamic> json) {
	if (json['area'] != null) {
		data.area = json['area'].toString();
	}
	if (json['companyLogo'] != null) {
		data.companyLogo = json['companyLogo'].toString();
	}
	if (json['licensePic'] != null) {
		data.licensePic = json['licensePic'].toString();
	}
	if (json['companyName'] != null) {
		data.companyName = json['companyName'].toString();
	}
	if (json['contact'] != null) {
		data.contact = json['contact'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['faRen'] != null) {
		data.faRen = json['faRen'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['title'] != null) {
		data.title = json['title'].toString();
	}
	if (json['type'] != null) {
		data.type = json['type'] is String
				? int.tryParse(json['type'])
				: json['type'].toInt();
	}
	if (json['createDate'] != null) {
		data.createDate = json['createDate'].toString();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['remark'] != null) {
		data.remark = json['remark'].toString();
	}
	if (json['phone'] != null) {
		data.phone = json['phone'].toString();
	}
	if (json['wxaccount'] != null) {
		data.wxaccount = json['wxaccount'].toString();
	}
	return data;
}

Map<String, dynamic> supplierListToJson(SupplierList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['area'] = entity.area;
	data['companyLogo'] = entity.companyLogo;
	data['licensePic'] = entity.licensePic;
	data['companyName'] = entity.companyName;
	data['contact'] = entity.contact;
	data['name'] = entity.name;
	data['faRen'] = entity.faRen;
	data['id'] = entity.id;
	data['title'] = entity.title;
	data['type'] = entity.type;
	data['createDate'] = entity.createDate;
	data['status'] = entity.status;
	data['remark'] = entity.remark;
	data['phone'] = entity.phone;
	data['wxaccount'] = entity.wxaccount;
	return data;
}